import ij.ImagePlus;
import ij.plugin.filter.PlugInFilter;
import ij.process.ColorProcessor;
import ij.process.ImageProcessor;

/* This plugin inverts a RGB color image. */

public class Color_Rgb_Test implements PlugInFilter {

	public int setup(String arg, ImagePlus imp) {
		return DOES_RGB;
	}

	public void run(ImageProcessor ip) {
		ColorProcessor cp = (ColorProcessor) ip;
		int[] RGB = new int[3];

		for (int v = 0; v < cp.getHeight(); v++) {
			for (int u = 0; u < cp.getWidth(); u++) {
				//get this color pixel as an int[]
				cp.getPixel(u, v, RGB);
				//extract the RGB components of this pixel:
				int red 	= RGB[0];
				int green 	= RGB[1];
				int blue 	= RGB[2];
				//invert all three channels:
				RGB[0] = (255 - red);
				RGB[1] = (255 - green);
				RGB[2] = (255 - blue);

				//modify this pixel
				cp.putPixel(u, v, RGB);
			}
		}
	}
}